#include "cserialprint.h"

QSerialPort* CSerialPrint::m_serial=new QSerialPort();
void CSerialPrint::Init(const QString &strPortName, QSerialPort::BaudRate baud)
{
    m_serial->setPortName(strPortName);
    m_serial->setBaudRate(baud);
    m_serial->setReadBufferSize(64);

}

bool CSerialPrint::Open()
{
    if(m_serial->isOpen()) return true;
    return m_serial->open(QIODevice::ReadWrite);
}
bool CSerialPrint::Close()
{
    m_serial->close();
    return !m_serial->isOpen();
}
bool CSerialPrint::write(const char *data, qint64 len)
{
    return m_serial->write(data,len)>0;
}
bool CSerialPrint::write(const char *data)
{
     return m_serial->write(data)>0;
}
bool CSerialPrint::write(const QByteArray &data)
{
     return m_serial->write(data)>0;
}
